package com.bckj.fastboot.iot.biz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bckj.fastboot.iot.common.dto.query.IotProtocolDisplaySetQuery;
import com.bckj.fastboot.iot.common.dto.response.IotProtocolDisplaySetResponse;
import com.bckj.fastboot.iot.common.entity.IotProtocolDisplaySet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

/**
 * IotProtocolDisplaySetMapper
 *
 * @author wfc
 * @date 2025/10/30 17:50
 **/
@Mapper
public interface IotProtocolDisplaySetMapper extends BaseMapper<IotProtocolDisplaySet> {

    @Select(
            """
        select * from iot_protocol_display_set
        where id = #{id}
        """
    )
    IotProtocolDisplaySetResponse findById(Long id);

    @SelectProvider(type = IotProtocolDisplaySetProvider.class, method = "findList")
    List<IotProtocolDisplaySetResponse> findList(IotProtocolDisplaySetQuery query);

    class IotProtocolDisplaySetProvider {

        public String findList(IotProtocolDisplaySetQuery query) {
            SQL sql = new SQL();
            sql.SELECT("pds.*");
            sql.FROM("iot_protocol_display_set pds");
            listWhere(sql, query);
            return sql.toString();
        }

        private void listWhere(SQL sql, IotProtocolDisplaySetQuery query) {

        }
    }
}
